﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using ZFY.DDD.Domain.Entities.AggregateRoot;

namespace ZFY.DDD.Domain.Repositories
{

    public interface IBaseRepository<TEntity,TKey>:IBaseRepository<TEntity> where TEntity :  class,IEntity<TKey>
    {
        Task<TEntity> GetByIdIncludeNavAsync(TKey id);
  
    }
    public interface IBaseRepository<TEntity> where TEntity:class
    {

        Task  AddAsync(TEntity entity);
        Task AddRangeAsync(List<TEntity> entities);
        Task UpdateRangeAsync(List<TEntity> entities);
        Task DeleteAsync(TEntity entity);
        Task DeleteAsync(int key);
        Task DeleteRangeAsync(List<TEntity> entities);
        Task<TEntity> SingleAsync(Expression<Func<TEntity, bool>> expression);
        Task<IQueryable<TEntity>> GetQueryableAsync();
        Task<IQueryable<TEntity>> WhereAsync(Expression<Func<TEntity, bool>> expression);
        Task<bool> AnyAsync(Expression<Func<TEntity, bool>> expression);
        Task<TEntity> FindAsync(int key);
        Task UpdateAsync(TEntity entity);
        
        Task<TEntity> SingleIncludeNavAsync(Expression<Func<TEntity, bool>> expression);
        Task<int> SaveChangesAsync();
    }
}